<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .top {
            height: 20px;
            width: 250px;
            margin-left: 10px;
            margin-top: 10px;
            font-weight: 700;
            display: flex;
            justify-content: space-between;
        }

        .top p:nth-child(2) {
            font-size: 12px;
            color: red;
            padding-top: 5px;
        }

        .content {
            height: 300px;
            width: 400px;
            /* background-color: aqua; */
        }

        .content ul {
            padding-top: 20px;
            padding-left: 30px;
            list-style: none;
        }

        .content ul li {
            color: rgba(255, 0, 0, 0.43);
            padding-top: 5px;
        }
    </style>
</head>

<body>
    <!-- 渲染不定页新闻 -->
    <div class="top">
        <p>百度新闻&gt;</p>
        <p>换一换</p>
    </div>
    <div class="content">
    </div>
</body>

</html>
<script>
    function page() {
        var arr = [
            { new: '继续为各国来华投资提供便利', new1: '乌市一方舱有卖淫嫖媢?警方回应热', new2: '红月亮"遇上月掩天王星' },
        ]
        var cont = document.querySelector('.content')
        var Ul = arr.map((item) => {
            return `
        <ul>
            <li>1${item.new}</li>
            <li>2${item.new1}</li>
            <li>3${item.new2}</li>
        </ul>
        `
        })
        cont.innerHTML = Ul
    }
    page()
    function page2() {
        var arr = [
            { new3: '前10个月进出口同比增长9.5%', new4: '湖南一中学多名学生感染校长被免职', new5: '男子月薪5万试用3天被解雇' },
        ]
        var cont = document.querySelector('.content')
        var Ul = arr.map((item) => {
            return `
        <ul>
            <li>4${item.new3}</li>
            <li>5${item.new4}</li>
            <li>6${item.new5}</li>
        </ul>
        `
        })
        cont.innerHTML = Ul
    }
    function page3() {
        var arr = [
            { new5: '俄罗斯制裁74家外国公司%', new6: '深圳楼市双11也打折', new7: '男子月薪5万试用3天被解雇' },
        ]
        var cont = document.querySelector('.content')
        var Ul = arr.map((item) => {
            return `
        <ul>
            <li>7${item.new5}</li>
            <li>8${item.new6}</li>
            <li>9${item.new7}</li>
        </ul>
        `
        })
        cont.innerHTML = Ul
    }
    //创建一个计数器
    var count = 0
    //获取换一换按钮
    var change = document.querySelector(' .top p:nth-child(2)')
    //给换一换绑定点击事件
    change.onclick = function (e) {
        count += 1
        //点击之后重新进行渲染
        page2()
        if (count == 2) {
            page3()
        } else if (count == 3) {
            page()
            count=0
        }
    }






</script>